<script type="text/javascript">
    function TyxxcjMainCtrl($scope, $http, modalService) {
        var ctrl = this;
        this.page = ':root/components/manager/tyxxcj.html';
        this.toApply = function (item, viewOnly) {
            if (item) {
                this.cjzb = item.id;
                this.viewOnly = viewOnly;
                ctrl.page = ':root/components/manager/tyxxcjApply.html';
                return;
            }
            this.cjzb = null;
            this.viewOnly = null;
            $http.post(':root/tyxxcj/cjsz').success(function (r) {
                if (!r) {
                    modalService.warn('请联系管理员设置采集规划', 1500);
                    return;
                }
                var now = new Date();
                if (r.ksrq > now.getTime() || r.jzrq < now.getTime()) {
                    var ksrq = new Date(r.ksrq), jzrq = new Date(r.jzrq);
                    modalService.warn('不在信息采集时间范围内，信息采集时间为' + ksrq.toLocaleDateString() + "至" + jzrq.toLocaleDateString(), 1500);
                    return;
                }
                $http.post(':root/tyxxcj/getAuditNum').success(function (R) {
                    if (R < 1) {
                        ctrl.page = ':root/components/manager/tyxxcjApply.html';
                    } else {
                        modalService.warn('存在尚未完成的采集信息，不能再申请', 1500);
                    }
                });
            });
        };
        this.toQuery = function () {
            this.page = ':root/components/manager/tyxxcj.html'
        };
    }
</script>
<div ng-include="mainCtrl.page" ng-controller="TyxxcjMainCtrl as mainCtrl"></div>